#include "junix.h"
using namespace std;

int main(int argc, char **argv)
{
	srand( time(0));
	vector<int> V(20);
	generate(V.begin(),V.end(),
			boost::bind( modulus<int>(),
				boost::bind(rand), 20));
	ostream_iterator<int> oit(cout," ");

	copy(V.begin(),V.end(),oit);
	cout<<endl;

	transform(V.begin(),V.end(),
			V.begin(),
			negate<int>());
	copy(V.begin(),V.end(),oit);
	cout<<endl;

	transform(V.begin(),V.end(),
			V.begin(),
			negate<int>());
	copy(V.begin(),V.end(),oit);
	cout<<endl;

	transform(V.begin(), V.end(),
			V.begin(),
			bind2nd( modulus<int>(), 5));
	copy(V.begin(),V.end(),oit);
	cout<<endl;

	vector<int> v1(20),v2(20);
	generate(v1.begin(),v1.end(),
			boost::bind( modulus<int>(),
				boost::bind(rand), 20));
	generate(v2.begin(),v2.end(),
			boost::bind( modulus<int>(),
				boost::bind(rand), 20));
	vector<int> v3;
	copy(v1.begin(),v1.end(), oit);
	cout<<endl;
	copy(v2.begin(),v2.end(),oit);
	cout<<endl;

	transform(v1.begin(), v1.end(),
			v2.begin(),
			back_inserter(v3),
			plus<int>());
	copy(v3.begin(), v3.end(),oit);
	cout<<endl;

	transform(v1.begin(),v1.end(),
			v2.begin(),
			v3.begin(),
			multiplies<int>());
	copy(v3.begin(), v3.end(),oit);
	cout<<endl;
}
